using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace url2jpeg
{
    public partial class CaptureRange : Form
    {
        public scripts m_result;

        public CaptureRange()
        {
            InitializeComponent();
        }

        private void btnCapOK_Click(object sender, EventArgs e)
        {
            m_result = new scripts();
            string[] ips = txtIP.Text.Split('.');
            int timeout = Convert.ToInt32(txtCapTimeout.Text);
            if (ips.Length == 4)
            {
                int[] nips = new int[4];
                for (int i=0; i<4; i++)
                    nips[i] = Convert.ToInt32(ips[i]);

                for (int i = 0; i < Convert.ToInt32(txtIPLength.Text); i++)
                {
                    scriptData sd = new scriptData();
                    sd.name = string.Format("{0}.{1}.{2}.{3}", nips[0], nips[1], nips[2], nips[3]);
                    sd.url = string.Format("http://{0}", sd.name);
                    sd.bRemoveScrollBar = true;
                    sd.bAutoResize = true;
                    sd.timeOut = timeout;
                    sd.capture = captureMode.Full;
                    sd.format = formatMode.Jpeg;
                    sd.initialSize = new Size(1024, 768);

                    m_result.scriptList.Add(sd);

                    for (int j = 4; j > 0; j--)
                    {
                        nips[j - 1]++;
                        if (nips[j - 1] <= 255)
                            break;
                    }
                }
            }
            DialogResult = DialogResult.OK;
        }
    }
}